package cn.com.sise.dao.impl;

import cn.com.sise.dao.UserDao;
import cn.com.sise.pojo.User;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

@Repository
public class UserDaoImpl
implements UserDao
{
@Resource
private JdbcTemplate jdbcTemplate;

@Override
public User login(User user)
{
String sql="select * from tb_user where account=? and password=?";
Object[] params=new Object[]{user.getAccount(), user.getPassword()};
RowMapper<User> rowMapper= BeanPropertyRowMapper.newInstance(User.class);

try
{
User userr = jdbcTemplate.queryForObject(sql, rowMapper, params);
return userr;
}

catch(DataAccessException e) {return null;}

}

};//class UserDaoImpl

